
#include "cItem.h"

//Constructor
cItem::cItem()
{

}
cItem::~cItem()
{

}

//Sprite correspondiente al item
void cItem::GetRect(RECT *rc,item *object)
{
	object->y-=256;
	switch(object->obj)
	{
		case 0:
			//House
			object->y-=256;
			SetRect(rc,0,0,512,512);
			break;	
		case 1:
			//Rock 1
			SetRect(rc,0,0,256,256);
			break;
		case 2:
			//Rock 2
			SetRect(rc,256,0,512,256);
			break;
		case 3:				
			//Rock 3
			SetRect(rc,0,256,256,512);
			break;
		case 4:
			//Rock 4
			SetRect(rc,256,256,512,512);
			break;			
	}

}

bool cItem::LoadList(char *inname)
{
	int x,y,obj,i;
	ifstream infile(inname);

    if (!infile)
        return false;
	
	//Read width of image
	infile >> nitems;

	//Reserve memory for vector
	ilist = new item[nitems];

	//Create list
	for(i=0; i<nitems; i++)
	{
			infile >> ilist[i].x;
			infile >> ilist[i].y;
			infile >> ilist[i].obj;
	}
	return true;
}
